<template>
   <div>
       <searchForm :formData="formData"></searchForm>
      <commonTable :columnData="columnData" :tableData="onlieList" :total="total">
         <template #loginTime="{row}">
            {{parseTime(row.loginTime)}}
         </template>
        <template #action="{row}">
          <el-button type="danger"  @click="toQuit(row.tokenId)">强退</el-button>
        </template>
      </commonTable>
   </div>
</template>
<script setup> 
  import {ref} from 'vue';
  import {list,forceLogout} from '@/api/monitor/online'
  import {parseTime} from '@/utils/ruoyi'
  let formData=ref([
   {
     label:'登录地址',
     prop:'username',
     type:'input'
   },
   {
     label:'用户名称',
     prop:'password',
     type:'input'

   }
  ])

  let columnData=ref([
    {
      label:'序号',
      type:'index'
    },
    {
      label:'会话编号',
      prop:'tokenId',
    },
    {
      label:'登录名称',
      prop:'userName',
    },
    {
      label:'部门名称',
      prop:'deptName',
    },
    {
      label:'主机',
      prop:'ipaddr',
    },
    {
      label:'登录地点',
      prop:'username',
    },
    {
      label:'浏览器',
      prop:'browser',
    },
    {
      label:'操作系统',
      prop:'os',
    },
    {
      label:'登录时间',
      key:"loginTime"
    },
    {
      label:'操作系统',
      key:"action"
    },
  ])
  let onlieList=ref([])
  let total=ref(0)
//   在线用户
  let getList=async ()=>{
   let res=await list();
   console.log(res,"0-00000000")
   onlieList.value=res.rows
   total.value=res.total;
  }
  getList();

//   强退
let toQuit=async (tokenId)=>{
  let res=await forceLogout(tokenId);
 
    getList();

}

</script>
